package com.tx.admin.core.entity;


import java.util.List;

import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import com.alibaba.excel.annotation.ExcelProperty;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@MappedSuperclass
@Data
public abstract class TreeEntity<E> extends SuperEntity {

	@ApiModelProperty("标题")
	@ExcelProperty(value = "标题")
	private String label;
	
	@ApiModelProperty("父编号")
	@ExcelProperty(value = "父编号")
	private String parentId;
	
	@Transient
	private E parent;
	
	@Transient
	private List<E> children;

	@Override
	public void init() {

		if(StringUtils.isBlank(this.parentId)){
			this.parentId="0";
		}
		super.init();
	}
}
